﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

using Microsoft.Practices.Unity;

using ERPStore.Extensions;

namespace ERPStore.Indexers.Lucene
{
	public static class TaskHelper
	{
		public static ERPStore.Models.TaskEntry CreateIndexationTask()
		{
			var connectorService = GlobalConfiguration.Configuration.DependencyResolver.GetService<ERPStore.Services.IConnectorService>();
			var Logger = GlobalConfiguration.Configuration.DependencyResolver.GetService<ERPStore.Logging.ILogger>();
			var settings = GlobalConfiguration.Configuration.DependencyResolver.GetService<Models.Settings>();

			var task = new ERPStore.Models.TaskEntry();
			task.Period = ERPStore.Models.ScheduledTaskTimePeriod.Day;
			task.Interval = 1;
			task.StartHour = 3;
			task.StartMinute = 0;
			task.Name = "Create lucene catalog";

			var parameters = new Dictionary<string, object>();
			parameters.Add("IndexPath", settings.Path);
			task.WorkflowProperties = parameters;

			task.GetActivityInstance = () => { return new Workflows.Activities.ScheduledBuilder(); };

			return task;
		}
	}
}
